#include <graphics.h>
#include <stdio.h>
#include <conio.h>
#include <time.h>
#include <stdlib.h>
#include "EasyXPng.h"
#define  WIDTH 250  
#define  HEIGHT 600
#define  PLACE HEIGHT/3*2
#define SPAN 10 //跳跃动画间隔时间(/ms)
int thickness=25;//墙面的厚度
class Barrier{
public:
	int isShow;//0,1分别对应是否出现障碍物(但是随着游戏进度，出现越来越快的情况我暂时还没想出怎么控制)
	int top;
	int width;
	int length;
	int position;//0,1分别对应出现在左右墙壁(可以用刚学的枚举类型)(我之后加）
};
Barrier barrierShort;//一种比较短的障碍物
Barrier barrierLong;//后期出现较多的比较大的障碍物(暂时还没写)
int main()
{
	initgraph(WIDTH,HEIGHT);//初始化背景
	srand((unsigned)time(NULL));
	setfillcolor(WHITE);
	while(1)
	{
		barrierShort.isShow=rand()%2;
		barrierShort.position=rand()%2;
		barrierLong.isShow=rand()%2;
		barrierLong.position=rand()%2;
		if (barrierShort.isShow=rand()%2)//判断是否出现
		{
			barrierShort.top=0;
			barrierShort.width=5;
			barrierShort.length=20;
			if(barrierShort.position)//判断出现位置()
			{
				fillrectangle(thickness
					,barrierShort.top
					,thickness+barrierShort.length
					,barrierShort.top+barrierShort.width);
				while(barrierShort.top<=HEIGHT)
				{
					barrierShort.top++;
					BeginBatchDraw();
					cleardevice();
					fillrectangle(thickness
						,barrierShort.top
						,thickness+barrierShort.length
						,barrierShort.top+barrierShort.width);
					Sleep(10);
					EndBatchDraw();
				}
			}
			else
	 			{					
				while(barrierShort.top<=HEIGHT)
				{
					BeginBatchDraw();
					cleardevice();
					fillrectangle(WIDTH-thickness-barrierShort.length
						,barrierShort.top
						,WIDTH-thickness
						,barrierShort.top+barrierShort.width);
					Sleep(10);
					EndBatchDraw();
					barrierShort.top++;
				}

			}
		}
	}
	_getch();
	return 0;
}